//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#include "../Argument.h"

using namespace Native::Compiling;
using namespace Native::Compiling::Sql;

CArgument::CArgument() :
    _output(false)
{
}

CArgument::CArgument(C_ARGUMENT& that) :
    CField(that),
    _name(that._name),
    _value(that._value),
    _output(that._output)
{
}

CArgument::CArgument(C_ARGUMENT&& that) :
    CField(that),
    _name(that._name),
    _value(that._value),
    _output(that._output)
{
}

CArgument::~CArgument()
{
}

wstring CArgument::ToString() const
{
    wchar_t cstring[128] = {0};
    wstring string(CField::ToString());

    wsprintf(
        cstring,
        L"Name:[%s], Value:[%s], Output:[%s]",
        _name.ToCString(),
        _value.ToCString(),
        _output.ToString().c_str());

    string.append(L",");
    string.append(cstring);

    return move(string);
}

bool CArgument::operator==(C_ARGUMENT& rvalue) const
{
    return
        CField::operator==(rvalue) &&
        _name == rvalue._name &&
        _value == rvalue._value &&
        _output == rvalue._output;

}

bool CArgument::operator!=(C_ARGUMENT& rvalue) const
{
    return !operator==(rvalue);
}

void CArgument::Clear()
{
    CField::Clear();

    _name = EMPTY_STRING;
    _value = EMPTY_STRING;
    _output = false;
}

CString CArgument::ToCode() const
{
    return EMPTY_STRING;
}

C_ARGUMENT& CArgument::operator=(C_ARGUMENT& rvalue)
{
    CField::operator=(rvalue);

    _name = rvalue._name;
    _value = rvalue._value;
    _output = rvalue._output;

    return *this;
}
